package com.kgc.storeprovider.controller;

import com.kgc.basic.util.ResponseMsg;
import com.kgc.store.pojo.CostAdjustment;
import com.kgc.store.remote.CostAdjustmentRemote;
import com.kgc.storeprovider.service.CostAdjustmentService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;
@Controller
public class CostAdjustmentController implements CostAdjustmentRemote {

    @Autowired
    private CostAdjustmentService costAdjustmentService;

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public ResponseMsg getOne(@RequestParam("code") String code) {
        logger.info("CostAdjustmentController getOne code:"+code);
        ResponseMsg responseMsg = costAdjustmentService.selectByCode(code);
        logger.debug("costAdjustmentService selectByCode responseMsg:"+responseMsg+",code:"+code);
        return responseMsg;
    }

    @Override
    public ResponseMsg getPage(@RequestBody Map<String, Object> map){
        logger.info("CostAdjustmentController getPage map:"+map);
        ResponseMsg responseMsg = costAdjustmentService.selectByPage(map);
        logger.debug("costAdjustmentService selectByPage responseMsg:"+responseMsg+",map:"+map);
        return responseMsg;
    }

    @Override
    public ResponseMsg add(@RequestBody CostAdjustment costAdjustment){
        logger.info("CostAdjustmentController add costAdjustment:"+costAdjustment);
        ResponseMsg responseMsg = costAdjustmentService.add(costAdjustment);
        logger.debug("costAdjustmentService add responseMsg:"+responseMsg+",costAdjustment:"+costAdjustment);
        return responseMsg;
    }

    @Override
    public ResponseMsg update(@RequestBody CostAdjustment costAdjustment){
        logger.info("CostAdjustmentController update costAdjustment:"+costAdjustment);
        ResponseMsg responseMsg = costAdjustmentService.update(costAdjustment);
        logger.debug("costAdjustmentService update responseMsg:"+responseMsg);
        return responseMsg;
    }

    @Override
    public ResponseMsg del(@RequestParam("code") String code) {
        logger.info("CostAdjustmentController del costAdjustment:"+code);
        ResponseMsg responseMsg = costAdjustmentService.del(code);
        logger.debug("costAdjustmentService del responseMsg:"+responseMsg);
        return responseMsg;
    }

    @Override
    public ResponseMsg importProChange(Map<String, Object> map) {
        logger.info("CostAdjustmentController importProChange map:"+map);
        ResponseMsg responseMsg = costAdjustmentService.insert(map);
        logger.debug("costAdjustmentService importProChange responseMsg:"+responseMsg);
        return responseMsg;
    }

    @Override
    public ResponseMsg changePrice(CostAdjustment costAdjustment) {
        logger.info("CostAdjustmentController changePrice costAdjustment:"+costAdjustment);
        ResponseMsg responseMsg = costAdjustmentService.changePrice(costAdjustment);
        logger.debug("costAdjustmentService changePrice responseMsg:"+responseMsg);
        return responseMsg;
    }

}
